
<template>
  <div class="header">
    <el-form ref="form" :model="form">
      <div class="search">
        <el-form-item label="审核状态" class="label">
          <el-select placeholder="请选择审核状态" class="input" />
        </el-form-item>
        <el-form-item label="访客姓名" class="label">
          <el-input v-model="form.name" class="input" placeholder="请输入访客姓名" />
        </el-form-item>
        <el-form-item label="访客类型" class="label">
          <el-select placeholder="请选择访客类型" class="input" />
        </el-form-item>
        <el-form-item label="访客类别" class="label">
          <el-select placeholder="请选择访客类别" class="input" />
        </el-form-item>

        <el-form-item>
          <el-button type="primary" size="mini" @click="onSubmit">查询</el-button>
        </el-form-item>
      </div>
    </el-form>
    <!-- 表格区域 -->
    <el-table
      :data="tableData"
      style="width: 100%"
      :header-cell-style="{background:'#ebecf0',color:'#3b3c3c'}"
     >
      <el-table-column type="index" width="100" label="序号" />
      <el-table-column prop="name" label="姓名" />
      <el-table-column prop="phone" label="手机号" />
      <el-table-column prop="door" label="身份证号" />
      <el-table-column prop="person" label="被访问人" />
      <el-table-column prop="xiaoqu" label="访问小区" />
      <el-table-column prop="type" label="访客类别" />
      <el-table-column prop="v" label="访客类型" />
      <el-table-column prop="time" label="提交时间" />
      <el-table-column label="审核状态">
        <template slot-scope="scope">
          <el-link type="warning" v-if="scope.row.status===0">待审核</el-link>
          <el-link type="success" v-else-if="scope.row.status===1">已通过</el-link>
          <el-link type="danger" v-else-if="scope.row.status===2">未通过</el-link>
        </template>
      </el-table-column>
      <el-table-column label="操作" width="100">
        <template slot-scope="scope">
          <el-button
            type="text"
            @click="dialogVisible = true"
          >{{ scope.row.option==='0'?'审核':'查看' }}</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 对话框 -->
    <el-dialog title :visible.sync="dialogVisible" width="55%" class="visitorcheck">
      <div class="dialog_box">
        <div class="dialog_content">
          <div class="dialog_title">申报信息</div>
          <el-form ref="form" :inline="true" :model="detail">
            <el-row :gutter="20">
              <el-col :span="9">
                <el-form-item label="访客姓名" class="label">
                  <el-input v-model="detail.community" class="input" />
                </el-form-item>
              </el-col>
              <el-col :span="10" :offset="4">
                <el-form-item label="身份证号" class="label">
                  <el-input v-model="detail.door" class="input" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row :gutter="20">
              <el-col :span="9" id="phone">
                <el-form-item label="手机号" class="label">
                  <el-input v-model="detail.time" class="input" />
                </el-form-item>
              </el-col>
              <el-col :span="10" :offset="4">
                <el-form-item label="访问小区" class="label">
                  <el-input v-model="detail.applyer" class="input" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row :gutter="20">
              <el-col :span="9">
                <el-form-item label="访客类别" class="label">
                  <el-input v-model="detail.time" class="input" />
                </el-form-item>
              </el-col>
              <el-col :span="10" :offset="4">
                <el-form-item label="访客类型" class="label">
                  <el-input v-model="detail.applyer" class="input" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row :gutter="20">
              <el-col :span="9">
                <el-form-item label="访问开始时间" class="label">
                  <el-date-picker
                    class="input"
                    v-model="value1"
                    type="datetime"
                    placeholder="选择日期时间"
                  ></el-date-picker>
                </el-form-item>
              </el-col>
              <el-col :span="10" :offset="4" style="position:relative">
                <el-form-item label="访问结束时间" class="label">
                  <el-date-picker
                    class="input"
                    v-model="value2"
                    type="datetime"
                    placeholder="选择日期时间"
                  ></el-date-picker>
                </el-form-item>
                <div class="time">
                  <div style="display:flex;float:right">
                    <el-select v-model="selectoption" @blur="getselectTime" class="selects">
                      <el-option
                        v-for="item in options"
                        style="width:100px"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value"
                      ></el-option>
                    </el-select>
                    <div
                      style="width:38px;height:36px;border:2px solid #f5f5f5;text-align:center;line-height:30px;"
                      :class="chooseTime=='0'?'visible':''"
                      @click="chooseOption('0')"
                    >年</div>
                    <div
                      style="width:38px;height:36px;border:2px solid #f5f5f5;text-align:center;line-height:30px;"
                      :class="chooseTime=='1'?'visible':''"
                      @click="chooseOption('1')"
                    >月</div>
                    <div
                      style="width:38px;height:36px;border:2px solid #f5f5f5;text-align:center;line-height:30px;"
                      :class="chooseTime=='2'?'visible':''"
                      @click="chooseOption('2')"
                    >周</div>
                  </div>
                </div>
              </el-col>
            </el-row>
            <el-row :gutter="20">
              <el-col :span="9">
                <el-form-item label="被访问人" class="label">
                  <el-input v-model="detail.applyer" class="input" />
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
        </div>
        <div class="dialog_content">
          <div class="dialog_title">历史申请</div>
          <el-table
            :data="gridData"
            border
            :header-cell-style="{background:'#ebecf0',color:'#3b3c3c'}"
          >
            <el-table-column type="index" label="序号" width="50" />
            <el-table-column property="date" label="访问开始时间" width="150" />
            <el-table-column property="data" label="访问结束时间" width="200" />
            <el-table-column property="name" label="被访问人" />
            <el-table-column property="name" label="访问小区" />
            <el-table-column property="name" label="访问类别" />
            <el-table-column property="name" label="访客类型" />
          </el-table>
        </div>
        <div class="dialog_content examineinfo">
          <div class="dialog_title">审核信息</div>
          <el-form>
            <el-form-item label="审核备注">
              <el-input type="textarea" placeholder="输入审核备注" />
            </el-form-item>
          </el-form>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">不通过</el-button>
        <el-button type="primary" @click="dialogVisible = false">通过</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: "Visitor",
  components: {},
  data() {
    return {
      form: {},
      tableData: [
        {
          name: "jyb",
          phone: "123",
          door: "3",
          person: "lx",
          xiaoqu: "wlgd",
          type: "123",
          v: "3",
          time: "2019",
          option: "0",
          status: 0
        },
        {
          name: "jyb",
          phone: "123",
          door: "3",
          person: "lx",
          xiaoqu: "wlgd",
          type: "123",
          v: "3",
          time: "2019",
          option: "1",
          status: 1
        },
        {
          name: "jyb",
          phone: "123",
          door: "3",
          person: "lx",
          xiaoqu: "wlgd",
          type: "123",
          v: "3",
          time: "2019",
          option: "2",
          status: 2
        }
      ],
      total: 100,
      page: 10,
      dialogVisible: false,
      value1: new Date(),
      value2: "",
      chooseTime: "0",
      options: [
        {
          value: "1",
          label: "1"
        }
      ],
      selectoption: "",
      // 历史信息
      gridData: [
        {
          date: "2016-05-02",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1518 弄"
        },
        {
          date: "2016-05-04",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1518 弄"
        },
        {
          date: "2016-05-01",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1518 弄"
        },
        {
          date: "2016-05-03",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1518 弄"
        }
      ],
      // 申报信息
      detail: {
        name: "张扬阳",
        sex: "男",
        community: "新丰苑三期",
        door: "1-301",
        address: "江苏-无锡",
        time: "2020-10-23 12:23:12",
        applyer: "王浩",
        reviewer: "周华东"
      }
    };
  },
  computed: {},
  watch: {},
  created() {},
  methods: {
    chooseOption(i) {
      if (i == "0") {
        this.options = [{ value: "1", label: "1" }];
        this.chooseTime = "0";
      }
      if (i == "1") {
        this.options = [
          { value: "1", label: "1" },
          { value: "2", label: "2" },
          { value: "3", label: "3" },
          { value: "4", label: "4" },
          { value: "5", label: "5" },
          { value: "6", label: "6" },
          { value: "7", label: "7" },
          { value: "8", label: "8" },
          { value: "9", label: "9" },
          { value: "10", label: "10" },
          { value: "11", label: "11" },
          { value: "12", label: "12" }
        ];
        this.chooseTime = "1";
      }
      if (i == "2") {
        this.chooseTime = "2";
        this.options = [
          { value: "1", label: "1" },
          { value: "2", label: "2" },
          { value: "3", label: "3" },
          { value: "4", label: "4" }
        ];
      }
    },
    getselectTime(e) {
      var date = this.value1.getTime();
      setTimeout(() => {
        if (this.chooseTime == "0") {
          this.value2 = date + 3600 * 24 * 365 * 1000;
        }
        if (this.chooseTime == "1") {
          this.value2 =
            date + 3600 * 24 * 30 * Number(this.selectoption) * 1000;
        }
        if (this.chooseTime == "2") {
          this.value2 = date + 3600 * 24 * 7 * Number(this.selectoption) * 1000;
        }
      }, 100);

      // Numner()
    }
  }
};
</script>
<style lang="scss" scoped>
.header {
  background: #ffffff;
  padding: 25px;
  padding-bottom: 100px;
  min-height: 800px;
  position: relative;
  .search {
    display: flex;
    align-items: flex-end;
    border-bottom: 2px solid #dcdee3;
    margin-bottom: 30px;
  }
  .input {
    width: 330px;
  }
  .label {
    margin-right: 20px;
    color: #666666;
    font-size: 14px;
  }
  .pagination {
    position: absolute;
    right: 0;
    bottom: 0;
    margin: 50px;
  }
  .examineinfo {
    margin-top: 20px;
  }
  .dialog_content {
    /* .dialog_title {
     font-size: 24px;
     font-weight: 800;
   } */
  }
  .visible {
    background: rgba(4, 118, 255, 0.1);
    border: 1px solid #0476ff;
  }
  .time {
    position: absolute;
    top: 72px;
    right: 63px;
    .selects {
      width: 100px;
    }
  }
  .dialog-footer {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 14px;
  margin-top: 8px;
}
}
</style>
<style scoped>
#phone /deep/ .el-form-item__label {
    width: 70px !important;
    text-align: left;
  }
.visitorcheck /deep/.el-dialog__header {
  padding:5px!important;
}
.visitorcheck /deep/.el-dialog__body {
  padding: 20px 15px!important;
}
</style>
